//Documentation complete
/**
 * @author Kazu
 * @version 2009MR22
 */

package problemDomain;

import static utilities.XMLTools.encodeEntities;

/**
 * SalesPerTimeReport class for menu item report.
 */
public class MenuItemReport implements Bean {
	
	/* Constants */
	
	private static final long serialVersionUID = -1584622527989878132L;
	
	/* END Constants */
	
	
	/* Attributes */
	
	private int id;
	private String name;
	private double cost;
	private double salesRevenue;
	private double grossProfit;
	
	/* END Attributes */
	
	
	/* Constructors */
	
	/**
	 * Constructs a <code>ItemCostPriceReport</code> with default values.
	 */
	public MenuItemReport () {
		id = 0;
		name = "";
		cost = 0.0;
		salesRevenue = 0.0;
		grossProfit = 0.0;
	}
	
	/**
	 * Constructs a <code>ItemCostPriceReport</code> with specified values.
	 * @param id Menu item ID
	 * @param name Menu item name
	 * @param cost Base cost of menu item
	 * @param salesRevenue the sales revenue
	 * @param grossProfit the gross profit
	 */
	public MenuItemReport (int id, String name, double cost, double salesRevenue, double grossProfit) {
		this.id = id;
		this.name = name;
		this.cost = cost;
		this.salesRevenue = salesRevenue;
		this.grossProfit = grossProfit;
	}

	/* Constructors */
	
	
	/* Accessors */
	
	/**
	 * Returns the ID.
	 * @return the ID of the report
	 */
	public int getId () {
		return id;
	}

	/**
	 * Returns the name.
	 * @return the name of the report
	 */
	public String getName () {
		return name;
	}

	/**
	 * Returns the cost.
	 * @return the cost of the report
	 */
	public double getCost () {
		return cost;
	}

	/**
	 * Returns the sales revenue.
	 * @return the sales revenue of the report
	 */
	public double getSalesRevenue () {
		return salesRevenue;
	}

	/**
	 * Returns the gross profit.
	 * @return the gross profit of the report
	 */
	public double getGrossProfit () {
		return grossProfit;
	}

	/* END Accessors */
	
	
	/* Mutators */

	/**
	 * Sets the ID.
	 * @param id the ID of the report
	 */
	public void setId (int id) {
		this.id = id;
	}

	/**
	 * Sets the name.
	 * @param name the name of the report
	 */
	public void setName (String name) {
		this.name = name;
	}

	/**
	 * Sets the cost.
	 * @param cost the cost of the report
	 */
	public void setCost (double cost) {
		this.cost = cost;
	}

	/**
	 * Sets the sales revenue.
	 * @param salesRevenue the sales revenue of the report
	 */
	public void setSalesRevenue (double salesRevenue) {
		this.salesRevenue = salesRevenue;
	}

	/**
	 * Sets the gross profit.
	 * @param grossProfit the gross profit of the report
	 */
	public void setGrossProfit (double grossProfit) {
		this.grossProfit = grossProfit;
	}
	
	/* END Mutators */
	
	
	/* (Bean) Methods */
	
	@Override
	public boolean isValid () throws ErrorBean {
		return true;
	}

	@Override
	public String toXML () {
		StringBuilder sb = new StringBuilder();
		sb.append("<menuitem-report>");
		sb.append("<id>" +id + "</id>");
		sb.append("<name>" + name + "</name>");
		sb.append("<cost>" + cost + "</cost>");
		sb.append("<sales-revenue>" + salesRevenue + "</sales-revenue>");
		sb.append("<gross-profit>" + grossProfit + "</gross-profit>");
		sb.append("</menuitem-report>");
		return encodeEntities(sb.toString());
	}

	/* END (Bean) Methods */
	
	
	/* (Object) Method */
	
	@Override
	public String toString () {
		return "ID: " + id + "\nName: " + name + "\nCost: " + cost +
				"\nSales Revenue: " + salesRevenue + "\nGross Profit: " + grossProfit;
	}
	
	/* END (Object) Method */
		
}
